/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.AccessManager.AttrRightChecker;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetDomain
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 50 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 55 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 56 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 58 */     boolean applyConfig = request.getAttributeBool("applyConfig", true);
/* 59 */     Set<String> reqAttrs = getReqAttrs(request, AttributeClass.domain);
/*    */     
/* 61 */     Element d = request.getElement("domain");
/* 62 */     String key = d.getAttribute("by");
/* 63 */     String value = d.getText();
/*    */     
/* 65 */     Domain domain = prov.get(Key.DomainBy.fromString(key), value);
/*    */     
/* 67 */     if (domain == null) {
/* 68 */       throw AccountServiceException.NO_SUCH_DOMAIN(value);
/*    */     }
/* 70 */     AdminAccessControl aac = checkDomainRight(zsc, domain, AdminRight.PR_ALWAYS_ALLOW);
/*    */     
/* 72 */     Element response = zsc.createElement(AdminConstants.GET_DOMAIN_RESPONSE);
/* 73 */     encodeDomain(response, domain, applyConfig, reqAttrs, aac.getAttrRightChecker(domain));
/*    */     
/* 75 */     return response;
/*    */   }
/*    */   
/*    */   public static void encodeDomain(Element e, Domain d) throws ServiceException {
/* 79 */     encodeDomain(e, d, true);
/*    */   }
/*    */   
/*    */   public static void encodeDomain(Element e, Domain d, boolean applyConfig) throws ServiceException {
/* 83 */     encodeDomain(e, d, applyConfig, null, null);
/*    */   }
/*    */   
/*    */   public static void encodeDomain(Element e, Domain d, boolean applyConfig, Set<String> reqAttrs, AccessManager.AttrRightChecker attrRightChecker) throws ServiceException
/*    */   {
/* 88 */     Element domain = e.addElement("domain");
/* 89 */     domain.addAttribute("name", d.getUnicodeName());
/* 90 */     domain.addAttribute("id", d.getId());
/* 91 */     Map attrs = d.getUnicodeAttrs(applyConfig);
/*    */     
/* 93 */     ToXML.encodeAttrs(domain, attrs, reqAttrs, attrRightChecker);
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 98 */     relatedRights.add(Rights.Admin.R_getDomain);
/* 99 */     notes.add(String.format("Attributes that are not allowed to be get by the authenticated admin will be returned as <a n=\"{attr-name}\" pd=\"1\"/>.To allow an admin to get all attributes, grant the %s right", new Object[] { Rights.Admin.R_getDomain.getName() }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetDomain.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */